//
//  LGTRWZPostPayCell.swift
//  KJLGT
//
//  Created by jenkin on 2019/8/23.
//  Copyright © 2019年 jenkin. All rights reserved.
//

import UIKit

class LGTRWZPostPayCell: UITableViewCell {

    var payMoney:UILabel?
    var decMoneyLabel:UILabel?
    private var _model:Dictionary<String, Any>?
    var model:Dictionary<String, Any>{
        get{
            return _model ?? Dictionary.init()
        }set{
            _model = newValue
            self.setData()
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = UITableViewCell.SelectionStyle.none
        let titleLabel:UILabel = LGTViewCreateUtil.share.createLabel(textAlignment: NSTextAlignment.left, textColor: TextColor, fontSize: SizeFitFloat(15), text: "需支付：")
        self.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { (make) in
            make.left.equalTo(SizeFit(13))
            make.height.equalTo(SizeFit(15))
            make.top.equalTo(SizeFit(14))
        }
        
        self.payMoney = LGTViewCreateUtil.share.createLabel(textAlignment: NSTextAlignment.left, textColor: YellowColor, fontSize: SizeFitFloat(15), text: "500")
        self.addSubview(self.payMoney!)
        self.payMoney!.snp.makeConstraints { (make) in
            make.left.equalTo(titleLabel.snp_rightMargin).offset(SizeFit(8))
            make.height.equalTo(SizeFit(15))
            make.top.equalTo(SizeFit(14))
        }
        
        let button:UIButton = LGTViewCreateUtil.share.createLGTButton(image: "questionmark", selected: "questionmark", dW: SizeFitFloat(5), dH: SizeFitFloat(5))
        self.addSubview(button)
        button.snp.makeConstraints { (make) in
            make.width.height.equalTo(SizeFitFloat(21))
            make.top.equalTo(SizeFit(14))
            make.right.equalTo(-SizeFit(14))
        }
        
        self.decMoneyLabel = LGTViewCreateUtil.share.createLabel(textAlignment: NSTextAlignment.left, textColor:GrayColor , fontSize: SizeFitFloat(12), text: "任务费+服务费5%+保证金20%（保证金在任务下架后退还）")
        self.addSubview(self.decMoneyLabel!)
         self.decMoneyLabel!.snp.makeConstraints { (make) in
            make.left.equalTo(SizeFit(13))
            make.right.equalTo(SizeFit(-11))
            make.height.equalTo(SizeFit(12))
            make.top.equalTo(SizeFit(43))
        }
        
        let line:UIImageView = LGTViewCreateUtil.share.createLineView()
        self.addSubview(line)
        line.snp.makeConstraints { (make) in
            make.top.equalTo(65)
            make.height.equalTo(1)
            make.left.equalTo(SizeFitFloat(13))
            make.right.equalTo(SizeFitFloat(-11))
            make.bottom.equalTo(0)
        }
    }
    
    func setData(){
        self.payMoney?.text = self.model["payStr"] as? String
        let commission_rate:CGFloat = self.model["commission_rate"] as? CGFloat ?? 0
        let deposit_rate:CGFloat = self.model["deposit_rate"] as? CGFloat ?? 0
        self.decMoneyLabel?.text = "任务费+服务费\(commission_rate)%+保证金\(deposit_rate)%（保证金在任务下架后退还）"
    }
}
